﻿@{
    ViewBag.Title = "MemberClassInfo";
}

@section scripts
{
    <script src="@Url.Content("~/Scripts/shared/share.js?v=Date()")" type="text/javascript"></script> 
    <script src="@Url.Content("~/Scripts/shared/shown.js")" type="text/javascript"></script>  
    <link href="~/Scripts/miniui/themes/default/medium-mode.css" rel="stylesheet" type="text/css" />      
}

<form id="form1" method="post">
            @Html.Partial("~/Views/Modular/Toolbars.cshtml")
        <div name="Base" title="会员分类" style="height:100%;overflow:hidden;margin-top:20px;margin-left:50px;">
            <table >
                <tr>
                    <td width="80px" height ="40px" align="right">
                        分类编码：</td>
                    <td width="280px" height ="40px">
                        <input name="FNumber" id="FNumber" class="mini-textbox" style="width:280px;" required="true" value="" TabIndex="1"/>
                    </td>
                </tr>
                <tr>
                    <td width="80px" height ="40px" align="right">
                        分类名称：</td>
                    <td width="280px" height ="40px">
                        <input id="FName" name="FName" class="mini-textbox " style="width:280px;" required="true" TabIndex="2"/>
                    </td>
                </tr>
                <tr>
                    <td width="80px" height ="40px" align="right">
                        折扣：</td>
                    <td width="280px" height ="40px">
                        <input name="FDiscount" class="mini-spinner" minValue="0" maxValue="1" changeOnMousewheel ="false"  value="1"
                            required="true" style="width:280px;" TabIndex="3" showbutton="false"  numberFormat="#,0.00" align="right"/>  
                    </td>
                </tr>
                <tr>
                    <td width="80px" height ="40px" align="right">
                        优惠类型：</td>
                    <td width="280px" height ="40px">
                        <input id="FTypeID" name="FTypeID" class="mini-combobox" style="width:280px;" showNullItem="false" 
                            allowInput="false" align="left" value ="0" data ="comType"/> 
                    </td>
                </tr>
                <tr>
                    <td width="80px" height ="40px" align="right">
                        卡片类型：</td>
                    <td width="280px" height ="40px">
                        <input id="FCardTypeID" name="FCardTypeID" class="mini-combobox" style="width:280px;" showNullItem="false" 
                            allowInput="false" align="left" value ="0" data ="cardType"/> 
                    </td>
                </tr>
                <tr>
                    <td width="80px" height ="40px" align="right">
                        赊账额度：</td>
                    <td width="280px" height ="40px">
                        <input id="FSheAmount" name="FSheAmount" class="mini-spinner " style="width:280px;"   
                            minValue="0" maxValue="99999999" changeOnMousewheel="false" value="0"
                            showbutton="false" format="#,0.00" align="right" selectOnFocus="true"/>
                    </td>
                </tr>
            </table>
            <table >
                <tr>
                    <td width="300px" height ="50px" align="right">
                        <div id="FAmountFlag" name="FAmountFlag"  class="mini-checkbox" readOnly="false" text="可充值" ></div>
                        <div id="FPointFlag" name="FPointFlag"  class="mini-checkbox" readOnly="false" text="可积分" ></div>
                        <div id="FSheFlag" name="FSheFlag"  class="mini-checkbox" readOnly="false" text="可赊账" ></div>
                        <div id="FDefault" name="FDefault"  class="mini-checkbox" readOnly="false" text="微会员默认" ></div>
                        <div id="FAuto" name="FAuto" class="mini-checkbox" readOnly="false" checked="false" oncheckedchanged="setAuto" text="自动升级 "></div>
                    </td>                                      
                </tr>
            </table>

            <table>
                <tr>
                    <td>
                        
                    </td>
                </tr>
            </table>
            <table id="SetTable">
                <tr>
                    <td width="80px" height ="30px" align="right">升级方式：</td>
                    <td width="280px" height ="30px">
                        <input id="FType" name="FType" class="mini-combobox" style="width:280px;" valueField＝"id" textField="text" 
                            onvaluechanged="updateType" allowInput="false" align="left" value="-1" data="UpdateType"/>
                    </td>
                </tr>
                <tr>
                    <td width="80px" height ="35px" align="right">
                        <span id="typetitle">升级值：</span></td>
                    <td width="280px" height ="35px">
                        <input id="FUpdateValue" name="FUpdateValue" class="mini-spinner " style="width:280px;"   
                            minValue="0" maxValue="99999999" changeOnMousewheel="false" value="0"
                            showbutton="false" format="#,0.00" align="right" selectOnFocus="true"/>
                    </td>
                </tr>
                <tr>
                    <td colspan="2"></td>
                </tr>
            </table>

            <br />
        </div>
    <input name="FItemID" class="mini-hidden" />
</form>
<script>
    var comType = [{ "id": "0", "text": "折扣卡" },
                       { "id": "1", "text": "会员价" },
                       { "id": "2", "text": "零售价" },
                       { "id": "3", "text": "批发价" }];
    var cardType = [{ "id": "0", "text": "非IC卡" },
                       { "id": "1", "text": "IC卡" }];
    var UpdateType = [{ "id": "-1", "text": "不升级" },
            { "id": "0", "text": "按积分升级" },
            { "id": "1", "text": "按消费金额升级" },
            { "id": "2", "text": "按充值金额升级" }];

    mini.parse();

    function FormShown() {
        mini.getbyName("FName").focus();
    }

    //加载类别
    function SetClassData(data) {
        if (data.action == "new") {
            //跨页面传递的数据对象，克隆后才可以安全使用
            mini.getbyName("FItemID").setValue('0');
            NewClass();
        }
        else {
            mini.getbyName("FItemID").setValue(data.FItemID);
            mini.getbyName("FNumber").setValue(data.FNumber);
            mini.getbyName("FNumber").setEnabled(false);
            mini.getbyName("FName").setValue(data.FName);
            mini.getbyName("FTypeID").setValue(data.FTypeID);
            mini.getbyName("FCardTypeID").setValue(data.FCardType);
            mini.getbyName("FDiscount").setValue(data.FDiscount);
            mini.getbyName("FAmountFlag").setValue(data.FAmountFlag);
            mini.getbyName("FPointFlag").setValue(data.FPointFlag);
            mini.getbyName("FDefault").setValue(data.FDefault);
            mini.getbyName("FSheFlag").setValue(data.FSheFlag);
            mini.getbyName("FAuto").setValue(data.FAuto);
            mini.getbyName("FType").setValue(data.FType);
            mini.getbyName("FUpdateValue").setValue(data.FUpdateValue);
            mini.getbyName("FSheAmount").setValue(data.FSheAmount);
        }
    }

    //新增分类
    function NewClass() {
        mini.getbyName("FItemID").setValue("0");
        mini.getbyName("FNumber").setValue("");
        mini.getbyName("FName").setValue("");
        var jsonstr = '{"mSystemAppID":"' + parent.window.getSystemAppID() + '"}';
        $.post('NewMemberClass', { json: jsonstr }, function (data) {
            mini.getbyName("FNumber").setValue(data);
        });
        mini.getbyName("FAmountFlag").setValue("1");
        mini.getbyName("FPointFlag").setValue("1");
        mini.getbyName("FDefault").setValue("0");
        mini.getbyName("FName").focus();
    }

    //保存分类
    function SaveInfo() {
        mini.getbyName("SaveInfo").setEnabled(false);
        var form = new mini.Form("#form1");
        form.validate();
        if (form.isValid() == false) {
            mini.getbyName("SaveInfo").setEnabled(true);
            return;
        }
        var data = form.getData(true, false);
        var json = mini.encode(data);
        $.post("../MemberClass/SaveInfo", { json: json, mSystemAppID: parent.window.getSystemAppID() }, function (data) {
            var ret = mini.decode(data);
            if (ret.status == 1) {
                mini.showTips({ content: ret.msg, state: "success", x: "center", y: "top", timeout: 3000 });
                NewClass();
            }
            else {
                mini.alert("异常:" + ret.error);
            }
            mini.getbyName("SaveInfo").setEnabled(true);
        });
    }

</script>

